{
if (format.isImageFormat()) {
QTextImageFormat imageFormat = format.toImageFormat();
-
- const int width = qRound(imageFormat.width());
+ const int width = qRound(qBound(qreal(INT_MIN), imageFormat.width(), qreal(INT_MAX)));
const bool hasWidth = imageFormat.hasProperty(QTextFormat::ImageWidth) && width > 0;
- const int height = qRound(imageFormat.height());
+ const int height = qRound(qBound(qreal(INT_MIN), imageFormat.height(), qreal(INT_MAX)));
const bool hasHeight = imageFormat.hasProperty(QTextFormat::ImageHeight) && height > 0;
QSizeF size(width, height);
#include <qmath.h>
#include "qquickstyledtext_p.h"
#include <QQmlContext>
+#include <QtGui/private/qoutlinemapper_p.h>
+
+#ifndef QQUICKSTYLEDPARSER_COORD_LIMIT
+# define QQUICKSTYLEDPARSER_COORD_LIMIT QT_RASTER_COORD_LIMIT
+#endif
Q_LOGGING_CATEGORY(lcStyledText, "qt.quick.styledtext")
if (attr.first == QLatin1String("src")) {
image->url = QUrl(attr.second.toString());
} else if (attr.first == QLatin1String("width")) {
- image->size.setWidth(attr.second.toString().toInt());
+ bool ok;
+ int v = attr.second.toString().toInt(&ok);
+ if (ok && v <= QQUICKSTYLEDPARSER_COORD_LIMIT)
+ image->size.setWidth(v);
+ else
+ qCWarning(lcStyledText) << "Invalid width provided for <img>";
} else if (attr.first == QLatin1String("height")) {
- image->size.setHeight(attr.second.toString().toInt());
+ bool ok;
+ int v = attr.second.toString().toInt(&ok);
+ if (ok && v <= QQUICKSTYLEDPARSER_COORD_LIMIT)
+ image->size.setHeight(v);
+ else
+ qCWarning(lcStyledText) << "Invalid height provided for <img>";
} else if (attr.first == QLatin1String("align")) {
if (attr.second.toString() == QLatin1String("top")) {
image->align = QQuickStyledTextImgTag::Top;